package cn.schoolwow.quickdao.module.database.dql.response.flow.common;

import cn.schoolwow.quickdao.module.database.parent.domain.ResultSetConsumer;
import cn.schoolwow.quickdao.module.database.parent.flow.executor.ExecuteQueryConnectionFlow;
import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;

import java.sql.ResultSet;

public class ExecuteConditionStatementFlow implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        flowContext.startFlow(new ExecuteQueryConnectionFlow())
                .putTemporaryData("name", "执行复杂查询")
                .putReturnData("resultSetConsumer",new ResultSetConsumer() {
                    @Override
                    public void consumeResultSet(ResultSet resultSet) throws Exception {
                        flowContext.startFlow(new GetResultSetArrayFlow())
                                .putData("resultSet", resultSet)
                                .execute();
                    }
                })
                .execute();
    }

    @Override
    public String name() {
        return "执行复杂查询";
    }

}
